package com.itheima.demo;

import com.itheima.domain.Person;

import java.util.Arrays;

public class Demo_Stream {
    public static void main(String[] args) {
        String str = "张三,18,西安\n李四,15,北京\n王五,23,深圳\n赵六,10,广州\n田七,40,上海";
        String[] s = str.split("\n");
        Arrays.stream(s).map(p -> {
            String[] person = p.split(",");
            return new Person(person[0], Integer.parseInt(person[1]), person[2]);
        }).filter(p -> p.getAge() >= 18).forEach(person1 -> System.out.println(person1));
    }
}
